<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>[|.pageTitle|]</title>
    [|if .zTree|]
    <link rel="stylesheet" href="/static/zTree3/css/demo.css?t=5" type="text/css">
    <link rel="stylesheet" href="/static/zTree3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    [|end|]
    <meta charset="utf-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/main.css">
    <script src="/static/layui/layui.js?s=36"></script>
    <script src="/static/js/main.js?s=2124"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
    <form class="layui-form" >
        <div class="layui-inline  layui-form-item">
           
            <label class="layui-form-label" style="display:inline-block;width:100px;">房间信息：</label>
            <div class="layui-input-inline">
                <select name="roomslist" id = "roomslist" lay-verify="required" lay-search="">
                    <option value="0">--请选择--</option>
                </select>
            </div>
         
      
            <label class="layui-form-label"  style="display:inline-block;width:100px;">执行时间：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="befordatetime" placeholder="yyyy-MM-dd HH:mm:ss" value="[|.befor_date|]" readonly>
            </div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="afterdatetime" placeholder="yyyy-MM-dd HH:mm:ss" value ="[|.after_date|]" readonly>
            </div>
           
         
            <label class="layui-form-label" style="display:inline-block;width:100px;">执行状态：</label>
            <div class="layui-input-inline">
                <select name="bloodctrlstatus" id = "bloodctrlstatus" lay-search="">
                </select>
            </div>

             <div class="layui-btn-group" >
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="queryBtn">查询</button>
            </div>
        </div>
    </form>

    <table  class="layui-table" id = 'booldctrltable' lay-size="sm" lay-filter="layfilterbooldctrltable"> </table>
    <script type="text/html" id="operatebar">
        <div class="layui-btn-group"> 
             <td> 
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="bloodContrldel">删除</a>
            </td>
        </div>
    </script>
</div>

<script>
    var $;

    layui.config({
            base : "js/"
    }).use(['form','table','element','layer','jquery','laydate'], function(){
        var element = layui.element;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table
        $ = layui.jquery;
    //监听表格复选框选择
   // table.on('checkbox(demo)', function(obj){
    //   console.log(obj);
   // });

   
    GetMyXiaLaLset()
    GetMyStatuSelect()
    CreateMyTables(table)
    //方法级渲染
    form.render("select")
    //常规用法
    laydate.render({
        elem: '#befordatetime'
        ,type: 'datetime'
    });
    //时间选择器
    laydate.render({
         elem: '#afterdatetime'
        ,type: 'datetime' 
     });
  
    //监听工具条
   table.on('tool(layfilterbooldctrltable)', function(obj){
        var data = obj.data;
        if(obj.event === 'bloodContrldel'){
        
                if(data.Status != 0)
                {    
                    layer.alert("已经执行了，不能删除！", {
                        title: '不能删除'
                     }) 
                    return false
                }
                layer.confirm('真的删除【'+data.RoomName+'('+data.SerVerID+ ')】的血池池控制么？' , function(index){
                    var jsData = {
                                    'R_ID':data.Rid
                                    ,'Del_Type':1
                                    ,'I_RoomID':data.SerVerID
                                }
                    $.post('[|urlfor "SysRoomconfController.AjaxDel"|]', jsData, function (out) {
                            if (out.status == 0) {
                                layer.alert('删除成功了', {icon: 1},function(index){
                                window.location.reload();
                            });
                            } else {
                            layer.msg(out.message)
                        }
                    }, "json");

            });
        }
    });


    form.on('submit(queryBtn)', function(data) {
        var selObj = document.getElementById("roomslist");
        var befordatetime = document.getElementById("befordatetime");
        var afterdatetime = document.getElementById("afterdatetime");
        var bloodctrlstatus = document.getElementById("bloodctrlstatus");
        window.location.href="/sysroomconf/bloodcontrllist.html?ServerID="+selObj.value+"&Befor_Datetime="+befordatetime.value+"&After_Datetime="+afterdatetime.value+"&Blood_Ctrlstatus=" +bloodctrlstatus.value
        return false;
    });
}); 
function GetMyXiaLaLset(){
 
    var selObj = document.getElementById("roomslist");
    //var valObj = document.getElementById("val");
    //var texObj = document.getElementById("tex");
    // 关键是这几句
    var myData = [|.RoomList|]
    var curvalue = [|.curServerID|] 
    for ( var i = 0 ; i < myData.length;i ++)
    {
        var Option = document.createElement("option");
        Option.value = myData[i].ServerID;
        if(curvalue == myData[i].ServerID){
      
             Option.selected="selected";
        }

        Option.text ="(" + myData[i].ServerID + ")"+ myData[i].RoomName;
        selObj.options.add(Option);
    }

}

function CreateMyTables(thisTabble){
 
    var selObj = document.getElementById("roomslist");
    var befordatetime = document.getElementById("befordatetime");
    var afterdatetime = document.getElementById("afterdatetime");
    var bloodctrlstatus = document.getElementById("bloodctrlstatus");
    thisTabble.render({
        elem: '#booldctrltable'
        ,url:'/sysroomconf/bloodcontrllisttable'
        ,where: {
            Room_ID:selObj.value
            ,Befor_Datetime:befordatetime.value
            ,After_Datetime:afterdatetime.value
            ,Blood_Ctrlstatus:afterdatetime.value
            ,Blood_Ctrlstatus:bloodctrlstatus.value
            }
        ,cols: [[ //标题栏
            {field:'SerVerID',  title:'SerVerID',sort:true,height:300,width:160}
            ,{field:'RoomName',title:'房间',height:300,width:200}
            ,{field:'OperateTime', title:'执行时间',height:300,width:200}
            ,{field:'BloodScore', title:'血池配置目标值', height:300,width:300} 
            ,{field:'Status',title:'运行状态',height:300,width:100}
            ,{field:'OpTime',title:'添加时间', height:300,width:200}
            ,{title:'',width:1,height:300, align:'padding-left',rules:'all',toolbar: '#operatebar' }
                ]] 
        ,skin: 'row' //表格风格
        ,even: true
        ,page: true //是否显示分页
        ,limits: [20]
        ,limit: 20 //每页默认显示的数量
        ,width: 'full-10'
        ,rules: 'all'
        ,height: 'full-155'
    });
}
function GetMyStatuSelect(){
 
    var selObj = document.getElementById("bloodctrlstatus");
    var myData = ["--请选择--","未执行","已执行"];
    var myVaule = [|.cruCrtl_status|]
    for ( var i = 0 ; i < myData.length;i ++)
    {
        var Option = document.createElement("option");
        Option.value = i
        if(myVaule == i){
             Option.selected="selected";
        }

        Option.text = myData[i];
        selObj.options.add(Option);
    } 

}
    //  layer.alert(JSON.stringify(curvalue), {
       //       title: '最终的提交信息'
      //     }) 
</script>
</body>
</html>